package be.bonamis.umpire.business;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class GenerateReportUtils {

	/**
	 * Create the file with a bytes series.
	 * 
	 * @param os
	 * @throws IOException
	 */
	public static void createFile(ByteArrayOutputStream os, String fileName)
			throws IOException {
		FileOutputStream fout = new FileOutputStream(fileName);
		try {
			os.writeTo(fout);
			fout.flush();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			fout.close();
		}
	}

	public static void openFile(String fileName) {

		try {
			if ((new File(fileName)).exists()) {
				Process p = Runtime.getRuntime().exec(
						"rundll32 url.dll,FileProtocolHandler " + fileName);
				p.waitFor();
			} else {
				System.out.println("File is not exists");
			}

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
